package cn.com.code.design.workshop.impl;

import cn.com.code.design.redis.cluser.EGM;
import cn.com.code.design.workshop.ICacheAdapter;

import java.util.concurrent.TimeUnit;

/**
 * EGMC 集群适配器
 *
 * @author zhengpei
 * @date 2021/9/13
 */
public class EGMCacheAdapter implements ICacheAdapter {

  private EGM egm = new EGM();

  @Override
  public String get(String key) {
    return egm.gain(key);
  }

  @Override
  public void set(String key, String value) {
    egm.set(key, value);
  }

  @Override
  public void set(String key, String value, long timeout, TimeUnit timeUnit) {
    egm.setEx(key, value, timeout, timeUnit);
  }

  @Override
  public void del(String key) {
    egm.delete(key);
  }

}
